package xperiment.metaphor.model.entity;

import xperiment.metaphor.model.contact.Address;
import xperiment.metaphor.model.*;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * <strong>NOTE: This class will either be replaced or drastically changed</strong>
 * @author Mark Ashworth
 * @version 1.0.0
 * @deprecated for now because a client is a relationship between two companies not an entity on it's own
 */
public class Client extends DomainObject implements Named {
    
    /* The unique database id for the object */
    @Id @GeneratedValue(strategy=GenerationType.AUTO) 
    @Column(name = "client_id", unique = true, nullable = false)
    private Long id = null;
    
    /** The name of the object */
    private String name;
    
    /** The client's address */
    private Address address = new Address();
    
    /** The sites of the client */
    private List<Site> sites = new ArrayList<Site>();
    
    /** Whether the client is enabled */
    @Column(name = "enabled", nullable=true)
    private boolean enabled = true;
    
    /**
     * Creates the client with the name
     */
    public Client() {
        super();
    }
    
    /**
     * Creates the client with the name
     * @param name The client's name
     */
    public Client(String name) {
        this.name = name;
    }

    public Long getId() {
        return this.id;
    }
    
    @Override
    public String getName() {
        return this.name;
    }

    /**
     * The name of the client
     * @param name The new name of the object
     */
    public void setName(String name) {
        String old = this.name;
        this.name = name;        
        firePropertyChange("name", old, this.name);
    }
    
    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        Address old = getAddress();
        this.address = address;
        firePropertyChange("name", old, this.name);
    }
    
    /**
     * Returns the list of sites of the client
     * @return List<Site>
     */
    public List<Site> getSites() {
        return sites;
    }

    public void setSites(List<Site> sites) {
        this.sites = sites;
    }
    
    /**
     * Whether the user is enabled
     * @return boolean
     */
    public boolean isEnabled() {
        return this.enabled;
    }

    /**
     * Whether the user is enabled
     * @param enabled The new value
     */
    public void setEnabled(boolean enabled) {
        boolean old = this.enabled;
		this.enabled = enabled;
		firePropertyChange("enabled", old, this.enabled);
    }
}
